<extend name="desktop_default/template/base_index" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/account/style.css">
    <script type="text/javascript" src="__CDN__/jquery/2.1.1/jquery.min.js"></script>
</block>

<block name="area_top">

</block>

<block name="area_content">
    <div class="bg main2-content">
        <div class="register-wrap" id="register_form">
            <div class="title"><img src="__IMG__/account/register.png"></div>
            <div class="form-group" id="tip-wrap"></div>
            <div class="form-group" id="account_form">
                <label for="account" class="i account">帐号</label>
                <input type="text" id="account" name="account" placeholder="帐号" value="" autocomplete=off >
            </div>
            <div class="form-group">
                <label for="code" class="i code">验证码</label>
                <input type="text" id="code" name="code" placeholder="验证码" value="" autocomplete=off >
                <a class="btn code _post" href="javascript:void(0);" data-form="account_form"
                   data-url="{:U('mengwu/account/send_register')}" data-verify="verifyMobile" data-tip="正在发送..."
                   tabIndex="-1">获取验证码</a>
            </div>
            <div class="form-group">
                <label for="psw" class="i psw">密码</label><input type="password" id="psw" name="psw" placeholder="密码" value="" >
            </div>
            <div class="form-group">
                <label for="psw" class="i psw">再次输入密码</label><input type="password" id="psw2" name="psw2" placeholder="再次输入密码" value="" >
            </div>
            <div class="form-group">
                <label for="invite_code" class="i invite">邀请码(选填)</label><input type="text" id="invite_code" name="invite_code" placeholder="邀请码(选填)" value="{:I('get.invite')}" autocomplete=off>
            </div>
            <div class="form-group">
                <a class="btn register _post" data-url="{:U('mengwu/account/register')}" data-verify="verify" data-tip="正在注册..." data-form="register_form" href="javascript:void(0);">注册</a>
                <h4>注册即接受 <a href="{:U('mengwu/helpCenter/index')}#17" target="_blank">《萌屋使用协议》</a> 和 <a href="{:U('mengwu/helpCenter/index')}#18" target="_blank">《社区使用协议》</a> <a href="{:U('mengwu/account/login')}">已有帐号登陆?</a></h4>
            </div>
            <div class="form-group">
                <div class="other-login">
                    <em>快捷登录方式</em>
                    <a class="login weixin" href="{$weixin_login}" title="微信登录"></a>
                    <!--<a class="login weibo" href="javascript:void(0);" title="微博帐号登录"></a>-->
                </div>

            </div>
        </div>

    </div>
</block>

<block name="area_footer">
    <include file="desktop_default/template/footer_bottom" />
    <script type="text/javascript" src="__JS__/account/common.js"></script>
    <script type="text/javascript">
        function verify(data){
            var $r = "";
            var psw = "";
            var psw2 = "";
            $.each(data, function(i, field){
                name = field.name;
                value = $.trim(field.value);
                if(name=='account'){
                    var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
                    if(!reg.test(value)){
                        $r = '用户名必须为手机号码';
                        $('#account').focus().select();
                        return false;
                    }
                }
                if(name=='account' && value==""){
                    $r = '帐号不能为空';
                    $('#account').focus();
                    return false;
                }
                if(name=='code' && value==""){
                    $r = '验证码不能为空';
                    $('#code').focus();
                    return false;
                }
                if(name=='psw'){
                    psw = value;
                    if(value==""){
                        $r = '密码不能为空';
                        $('#psw').focus();
                        return false;
                    }
                    if(value.length<6){
                        $r = '密码长度不能小于6位';
                        $('#psw').focus();
                        return false;
                    }
                }
                if(name=='psw2'){
                    psw2 = value;
                }

            });
            if($r!='')return $r;
            if(psw!=psw2) {
                $r = '两次密码输入不一致';
                $('#psw2').focus();
            }
            return $r;
        }
        function verifyMobile(data) {
            var $r = "";
            $.each(data, function(i, field){
                name = field.name;
                value = $.trim(field.value);
                if(name=='account'){
                    var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
                    if(!reg.test(value)){
                        $r = '用户名必须为手机号码';
                        $('#account').focus().select();
                        return false;
                    }
                }
            });
            return $r;
        }
    </script>
</block>